# 698. 单词逆序
def reverse_string(s):
    chars = []
    for c in s:
        if str.isalpha(c):
            chars.append(c)
        elif c == '-':
            if chars and str.isalpha(chars[-1]):
                chars.append('-')
            elif chars and chars[-1] == '-':
                chars.pop()
                chars.append(' ')
            else:
                chars.append(' ')
        else:
            if chars and chars[-1] == '-':
                chars.pop()
            chars.append(' ')
    if chars and chars[-1] == '-':
        chars.pop()
    s = ''.join(chars)
    result = ' '.join(s.strip().split()[::-1])
    return result


if __name__ == '__main__':
    s = input()
    print(reverse_string(s))
